package com.congee02;

/**
 * 强引用测试
 * @author congee(congee02 @ 163.com)
 * @date 1/28/2023 6:09 PM
 */
public class StrongReferenceTest {

    public static void main(String[] args) {
        // 强引用不会被 JVM 回收
        StrongSampleObject object = new StrongSampleObject();
        System.gc();
        System.out.println("gc done");
        
        // 不可达状态
        object = null;
        System.gc();
        
    }
    
    private static class StrongSampleObject {
        @Override
        protected void finalize() throws Throwable {
            System.out.println("StrongSampleObject : doing finalize");
        }
    }
    
}
